#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
using namespace std;

int valcount(int x)
{
	int count = 0;
	while (x)
	{
		if (x % 10 == 2)
		{
			count++;
		}

		x /= 10;
	}

	return count;
}

int main()
{
	int L, R;
	cin >> L >> R;

	int sum = 0;

	for (int i = L; i <= R; i++)
		sum += valcount(i);

	cout << sum << endl;

	return 0;
}